using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace DataAccess
{
	/// <summary>
	/// Strongly-typed collection for the TblReposDetail class.
	/// </summary>
    [Serializable]
	public partial class TblReposDetailCollection : ActiveList<TblReposDetail, TblReposDetailCollection>
	{	   
		public TblReposDetailCollection() {}
        
        /// <summary>
		/// Filters an existing collection based on the set criteria. This is an in-memory filter
		/// Thanks to developingchris for this!
        /// </summary>
        /// <returns>TblReposDetailCollection</returns>
		public TblReposDetailCollection Filter()
        {
            for (int i = this.Count - 1; i > -1; i--)
            {
                TblReposDetail o = this[i];
                foreach (SubSonic.Where w in this.wheres)
                {
                    bool remove = false;
                    System.Reflection.PropertyInfo pi = o.GetType().GetProperty(w.ColumnName);
                    if (pi.CanRead)
                    {
                        object val = pi.GetValue(o, null);
                        switch (w.Comparison)
                        {
                            case SubSonic.Comparison.Equals:
                                if (!val.Equals(w.ParameterValue))
                                {
                                    remove = true;
                                }
                                break;
                        }
                    }
                    if (remove)
                    {
                        this.Remove(o);
                        break;
                    }
                }
            }
            return this;
        }
		
		
	}
	/// <summary>
	/// This is an ActiveRecord class which wraps the TblReposDetail table.
	/// </summary>
	[Serializable]
	public partial class TblReposDetail : ActiveRecord<TblReposDetail>, IActiveRecord
	{
		#region .ctors and Default Settings
		
		public TblReposDetail()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}
		
		private void InitSetDefaults() { SetDefaults(); }
		
		public TblReposDetail(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}
        
		public TblReposDetail(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}
		 
		public TblReposDetail(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}
		
		protected static void SetSQLProps() { GetTableSchema(); }
		
		#endregion
		
		#region Schema and Query Accessor	
		public static Query CreateQuery() { return new Query(Schema); }
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}
		}
		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("TblReposDetail", TableType.Table, DataService.GetInstance("DataAccess"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarId = new TableSchema.TableColumn(schema);
				colvarId.ColumnName = "ID";
				colvarId.DataType = DbType.Int32;
				colvarId.MaxLength = 0;
				colvarId.AutoIncrement = false;
				colvarId.IsNullable = false;
				colvarId.IsPrimaryKey = true;
				colvarId.IsForeignKey = false;
				colvarId.IsReadOnly = false;
				colvarId.DefaultSetting = @"";
				colvarId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarId);
				
				TableSchema.TableColumn colvarSerial = new TableSchema.TableColumn(schema);
				colvarSerial.ColumnName = "Serial";
				colvarSerial.DataType = DbType.String;
				colvarSerial.MaxLength = -1;
				colvarSerial.AutoIncrement = false;
				colvarSerial.IsNullable = true;
				colvarSerial.IsPrimaryKey = false;
				colvarSerial.IsForeignKey = false;
				colvarSerial.IsReadOnly = false;
				colvarSerial.DefaultSetting = @"";
				colvarSerial.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSerial);
				
				TableSchema.TableColumn colvarIdRepos = new TableSchema.TableColumn(schema);
				colvarIdRepos.ColumnName = "IdRepos";
				colvarIdRepos.DataType = DbType.Int32;
				colvarIdRepos.MaxLength = 0;
				colvarIdRepos.AutoIncrement = false;
				colvarIdRepos.IsNullable = true;
				colvarIdRepos.IsPrimaryKey = false;
				colvarIdRepos.IsForeignKey = false;
				colvarIdRepos.IsReadOnly = false;
				colvarIdRepos.DefaultSetting = @"";
				colvarIdRepos.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIdRepos);
				
				TableSchema.TableColumn colvarAvailable = new TableSchema.TableColumn(schema);
				colvarAvailable.ColumnName = "Available";
				colvarAvailable.DataType = DbType.Boolean;
				colvarAvailable.MaxLength = 0;
				colvarAvailable.AutoIncrement = false;
				colvarAvailable.IsNullable = true;
				colvarAvailable.IsPrimaryKey = false;
				colvarAvailable.IsForeignKey = false;
				colvarAvailable.IsReadOnly = false;
				colvarAvailable.DefaultSetting = @"";
				colvarAvailable.ForeignKeyTableName = "";
				schema.Columns.Add(colvarAvailable);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["DataAccess"].AddSchema("TblReposDetail",schema);
			}
		}
		#endregion
		
		#region Props
		  
		[XmlAttribute("Id")]
		[Bindable(true)]
		public int Id 
		{
			get { return GetColumnValue<int>(Columns.Id); }
			set { SetColumnValue(Columns.Id, value); }
		}
		  
		[XmlAttribute("Serial")]
		[Bindable(true)]
		public string Serial 
		{
			get { return GetColumnValue<string>(Columns.Serial); }
			set { SetColumnValue(Columns.Serial, value); }
		}
		  
		[XmlAttribute("IdRepos")]
		[Bindable(true)]
		public int? IdRepos 
		{
			get { return GetColumnValue<int?>(Columns.IdRepos); }
			set { SetColumnValue(Columns.IdRepos, value); }
		}
		  
		[XmlAttribute("Available")]
		[Bindable(true)]
		public bool? Available 
		{
			get { return GetColumnValue<bool?>(Columns.Available); }
			set { SetColumnValue(Columns.Available, value); }
		}
		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
        
        
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(int varId,string varSerial,int? varIdRepos,bool? varAvailable)
		{
			TblReposDetail item = new TblReposDetail();
			
			item.Id = varId;
			
			item.Serial = varSerial;
			
			item.IdRepos = varIdRepos;
			
			item.Available = varAvailable;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varId,string varSerial,int? varIdRepos,bool? varAvailable)
		{
			TblReposDetail item = new TblReposDetail();
			
				item.Id = varId;
			
				item.Serial = varSerial;
			
				item.IdRepos = varIdRepos;
			
				item.Available = varAvailable;
			
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		#endregion
        
        
        
        #region Typed Columns
        
        
        public static TableSchema.TableColumn IdColumn
        {
            get { return Schema.Columns[0]; }
        }
        
        
        
        public static TableSchema.TableColumn SerialColumn
        {
            get { return Schema.Columns[1]; }
        }
        
        
        
        public static TableSchema.TableColumn IdReposColumn
        {
            get { return Schema.Columns[2]; }
        }
        
        
        
        public static TableSchema.TableColumn AvailableColumn
        {
            get { return Schema.Columns[3]; }
        }
        
        
        
        #endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string Id = @"ID";
			 public static string Serial = @"Serial";
			 public static string IdRepos = @"IdRepos";
			 public static string Available = @"Available";
						
		}
		#endregion
		
		#region Update PK Collections
		
        #endregion
    
        #region Deep Save
		
        #endregion
	}
}
